package com.xbts.system.controller;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.page.TableDataInfo;
import com.xbts.common.log.annotation.Log;
import com.xbts.common.log.enums.BusinessType;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.system.domain.SysThirdSysPath;
import com.xbts.system.service.ISysThirdSysPathService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 第三方系统路径Controller
 * 
 * @author llk
 * @date 2023-12-22
 */
@Api(tags = "第三方系统路径管理")
@RestController
@RequestMapping("/third/path")
public class SysThirdSysPathController extends BaseController {

    @Autowired
    private ISysThirdSysPathService sysThirdSysPathService;

    /**
     * 查询第三方系统路径列表
     */
    @ApiOperation("获取第三方系统路径列表")
    @RequiresPermissions("system:path:list")
    @GetMapping("/list")
    public TableDataInfo list(SysThirdSysPath sysThirdSysPath) {
        startPage();
        List<SysThirdSysPath> list = sysThirdSysPathService.list(sysThirdSysPath.queryWrapper());
        return getDataTable(list);
    }

    /**
     * 获取第三方系统路径详细信息
     */
    @ApiOperation("获取第三方系统路径详细")
    @ApiImplicitParam(name = "id", value = "第三方系统路径ID", required = true, dataType = "Long", paramType = "path")
    @RequiresPermissions("system:path:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysThirdSysPathService.getById(id));
    }


    /**
     * 新增第三方系统路径
     */
    @ApiOperation("新增第三方系统路径")
    @RequiresPermissions("system:path:add")
    @Log(title = "第三方系统路径", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody SysThirdSysPath saveVO) {
        return toAjax(sysThirdSysPathService.saveSysThirdSysPath(saveVO));
    }

    /**
     * 修改第三方系统路径
     */
    @ApiOperation("更新第三方系统路径")
    @RequiresPermissions("system:path:edit")
    @Log(title = "第三方系统路径", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysThirdSysPath sysThirdSysPath) {
        return toAjax(sysThirdSysPathService.updateById(sysThirdSysPath));
    }

    /**
     * 删除第三方系统路径
     */
    @ApiOperation("删除第三方系统路径")
    @ApiImplicitParam(name = "ids", value = "第三方系统路径ID集合", required = true, dataType = "Long", paramType = "path")
    @RequiresPermissions("system:path:remove")
    @Log(title = "第三方系统路径", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids) {
        return toAjax(sysThirdSysPathService.removeByIds(ids));
    }

}
